<#macro sideMenu>
<h4 class="centered">${i18n.homework.sidebar_header!"Course materials"}</h4>
<hr/>
<#-- Course Home -->
    <#if (courseId?has_content && courseId > 0)>
    <div style="padding: 8px 15px; border-top: 1px solid #E5E5E5;">
        <a href="${baseUrl}/material/?course_id=${courseId}">${i18n.homework.courseHome!"Course home"}</a>
    </div>
    </#if>

    <#assign currentSectionTitle = "xxx">
<div class="accordion" id="accordion2">
    <div class="accordion-group">
        <#assign collapseNum = 0>
        <#list materials_titles as section_title>
        <#-- Empty section title, output material title without accordion. -->
            <#if section_title.getSectionTitle()?string == "">
                <div style="padding: 8px 15px;">
                    <a href="${baseUrl}/material/view/?material_id=${section_title.getId()}">${section_title.getTitle()}</a>
                </div>
            </#if>
            <#if (currentSectionTitle != section_title.getSectionTitle()?string && section_title.getSectionTitle()?string != "")>
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2"
                       href="#collapse${collapseNum}">
                    ${section_title.getSectionTitle()}
                    </a>
                </div>
                <div id="collapse${collapseNum}" class="accordion-body collapse <#if (currentCollapseNum?has_content && collapseNum == currentCollapseNum)>in</#if>">
                    <div class="accordion-inner">
                        <ul>
                            <#list materials_titles as title>
                                <#if (section_title.getSectionTitle() == title.getSectionTitle())>
                                    <li class="<#if (materialId?has_content && title.getId() == materialId)>active</#if>">
                                        <a href="${baseUrl}/material/view/?material_id=${title.getId()}&si=${collapseNum}">${title.getTitle()}</a>
                                    </li>
                                    <#if hwList?has_content && loggedOnUser?has_content && isEnrolled>
                                        <#assign hwCounter = 1>
                                        <#list hwList as hwork>
                                            <#if hwork?has_content && (hwork.getMaterialId() == title.getId())>
                                                <li class="sidebar-homework <#if hwork.getId() == homeworkId>active</#if>">
                                                    <i class="icon-time"></i>&nbsp;
                                                    <small>
                                                        <a href="${baseUrl}/homework/view/?homework_id=${hwork.getId()}&si=${collapseNum}">
                                                            ${hwork.getHomeWorkTitle()}
                                                        </a><br/>
                                                        ${i18n.homework.homework_expire_text}&nbsp;${hwork.getDueDate()}
                                                    </small>
                                                </li>
                                            </#if>
                                            <#assign hwCounter = hwCounter + 1>
                                        </#list>
                                    </#if>
                                </#if>
                            </#list>
                        </ul>
                    </div>
                </div>
                <#assign collapseNum = (collapseNum + 1)>
            </#if>
            <#assign currentSectionTitle = section_title.getSectionTitle()>

        </#list>
    </div> <#-- accordion-group -->
</div> <#-- accordion -->
</#macro>
